<?php
declare (strict_types = 1);

namespace app\middleware;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;

class Check
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        $key = "example_key";
        $rds=$next($request);

//        if (!in_array($request->pathinfo(),$this->url)){
        $token = $_SERVER['HTTP_TOKEN'];

        $decoded = JWT::decode($token, new Key($key, 'HS256'));
        if (empty($decoded)){
            return json(111);
        }
        return json(222);
//        return $rds;


//        }

    }
}
